const { sequelize } = require("@core/db");
const { Sequelize, Model } = require("sequelize");

class Complaint extends Model {}

Complaint.init(
  {
    complaint_id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    is_on: {
      type: Sequelize.BOOLEAN,
      defaultValue: true,
      comment: "是否展示",
    },

    uid: {
      type: Sequelize.INTEGER,
      allowNull: false,
      comment: "用户id",
    },
    imgs: {
      type: Sequelize.STRING,
      allowNull: false,
      comment: "图片地址",
    },
    area: {
      type: Sequelize.STRING,
      allowNull: false,
      comment: "区域",
    },
    content: {
      type: Sequelize.TEXT,
      allowNull: false,
      comment: "建议内容",
    },
  },
  {
    sequelize,
    tableName: "complaint",
  }
);

class Reply extends Model {}

Reply.init(
  {
    reply_id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    complaint_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      comment: "投诉id",
    },
    admin_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      comment: "管理员id",
    },
    content: {
      type: Sequelize.TEXT,
      allowNull: false,
      comment: "回复内容",
    },
  },
  {
    sequelize,
    tableName: "reply",
  }
);

module.exports = {
  Reply,
  Complaint,
};
